package com.justgame.project.cloud.common.util;

import org.springframework.lang.NonNull;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

public class MaskUtils {

    public static String phone(@NonNull String phoneNumber){
        if (StringUtils.isEmpty(phoneNumber)) {
            return phoneNumber;
        }
        Assert.isTrue(phoneNumber.matches("^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$"),"手机号格式不正确");
        return phoneNumber.substring(0, 3) + "*****" + phoneNumber.substring(8);
    }

}
